package view;

import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JButton;
import javax.swing.JTextField;

import model.kwalificatiebeheer.Competentie;

public class ViewCompetentiePanel extends JPanel implements Observer{
	
	private JTextField txtId;
	private JTextField txtNaam;
	private Competentie competentie;
	
	public ViewCompetentiePanel(Competentie competentie){
		this.competentie = competentie;
		competentie.addObserver(this);
		setVisible(true);		
		initGui();
	}
	
	private void initGui(){
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{1.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		JLabel lblNummer = new JLabel("Nummer:");
		GridBagConstraints gbc_lblNummer = new GridBagConstraints();
		gbc_lblNummer.anchor = GridBagConstraints.EAST;
		gbc_lblNummer.insets = new Insets(0, 0, 5, 5);
		gbc_lblNummer.gridx = 1;
		gbc_lblNummer.gridy = 1;
		add(lblNummer, gbc_lblNummer);
		
		txtId = new JTextField(competentie.getId());
		txtId.setEnabled(false);
		GridBagConstraints gbc_txtId = new GridBagConstraints();
		gbc_txtId.insets = new Insets(0, 0, 5, 5);
		gbc_txtId.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtId.gridx = 2;
		gbc_txtId.gridy = 1;
		add(txtId, gbc_txtId);
		txtId.setColumns(10);
		
		JLabel lblNaam = new JLabel("Naam:");
		GridBagConstraints gbc_lblNaam = new GridBagConstraints();
		gbc_lblNaam.anchor = GridBagConstraints.EAST;
		gbc_lblNaam.insets = new Insets(0, 0, 5, 5);
		gbc_lblNaam.gridx = 1;
		gbc_lblNaam.gridy = 2;
		add(lblNaam, gbc_lblNaam);
		
		txtNaam = new JTextField(competentie.getNaam());
		GridBagConstraints gbc_txtNaam = new GridBagConstraints();
		gbc_txtNaam.insets = new Insets(0, 0, 5, 5);
		gbc_txtNaam.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtNaam.gridx = 2;
		gbc_txtNaam.gridy = 2;
		add(txtNaam, gbc_txtNaam);
		txtNaam.setColumns(10);
		
		JButton btnOpslaan = new JButton("Opslaan");
		GridBagConstraints gbc_btnOpslaan = new GridBagConstraints();
		gbc_btnOpslaan.anchor = GridBagConstraints.EAST;
		gbc_btnOpslaan.insets = new Insets(0, 0, 5, 5);
		gbc_btnOpslaan.gridx = 2;
		gbc_btnOpslaan.gridy = 3;
		add(btnOpslaan, gbc_btnOpslaan);
	}

	public JTextField getTxtId() {
		return txtId;
	}

	public void setTxtId(JTextField txtId) {
		this.txtId = txtId;
	}

	public JTextField getTxtNaam() {
		return txtNaam;
	}

	public void setTxtNaam(JTextField txtNaam) {
		this.txtNaam = txtNaam;
	}

	public Competentie getCompetentie() {
		return competentie;
	}

	public void setCompetentie(Competentie competentie) {
		this.competentie = competentie;
	}

	@Override
	public void update(Observable o, Object arg) {
		// TODO Auto-generated method stub
		
	}
}
